home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 13 / CU Amiga Magazine's Super CD-ROM 13 (1997)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1997-08].iso / CUCD / Graphics / Ghostscript / src / libpng / pngconf.h < prev    next >
C/C++ Source or Header  |  1996-06-05  |  12KB  |  361 lines

  1.  
  2. /* pngconf.c - machine configurable file for libpng
  3.  
  4.    libpng 1.0 beta 3 - version 0.89
  5.    For conditions of distribution and use, see copyright notice in png.h
  6.    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  7.    May 25, 1996
  8.    */
  9.  
  10. /* Any machine specific code is near the front of this file, so if you
  11.    are configuring libpng for a machine, you may want to read the section
  12.    starting here down to where it starts to typedef png_color, png_text,
  13.    and png_info */
  14.  
  15. #ifndef PNGCONF_H
  16. #define PNGCONF_H
  17.  
  18. /* this is the size of the compression buffer, and thus the size of
  19.    an IDAT chunk.  Make this whatever size you feel is best for your
  20.    machine.  One of these will be allocated per png_struct.  When this
  21.    is full, it writes the data to the disk, and does some other
  22.    calculations.  Making this an extreamly small size will slow
  23.    the library down, but you may want to experiment to determine
  24.    where it becomes significant, if you are concerned with memory
  25.    usage.  Note that zlib allocates at least 32Kb also.  For readers,
  26.    this describes the size of the buffer available to read the data in.
  27.    Unless this gets smaller then the size of a row (compressed),
  28.    it should not make much difference how big this is.  */
  29.  
  30. #define PNG_ZBUF_SIZE 8192
  31.  
  32. /* While libpng currently uses zlib for it's compression, it has been designed
  33.    to stand on it's own.  Towards this end, there are two defines that are
  34.    used to help portability between machines.  To make it simpler to
  35.    setup libpng on a machine, this currently uses zlib's definitions, so
  36.    any changes should be made in zlib.  Libpng will check zlib's settings
  37.    and adjust it's own accordingly. */
  38.  
  39. /* if you are running on a machine where you cannot allocate more then
  40.    64K of memory, uncomment this.  While libpng will not normally need
  41.    that much memory in a chunk (unless you load up a very large file),
  42.    zlib needs to know how big of a chunk it can use, and libpng thus
  43.    makes sure to check any memory allocation to verify it will fit
  44.    into memory.
  45. #define PNG_MAX_ALLOC_64K
  46. */
  47. #ifdef MAXSEG_64K
  48. #define PNG_MAX_ALLOC_64K
  49. #endif
  50.  
  51. /* this protects us against compilers which run on a windowing system
  52.    and thus don't have or would rather us not use the stdio types:
  53.    stdin, stdout, and stderr.  The only one currently used is stderr
  54.    in png_error() and png_warning().  #defining PNG_NO_STDIO will
  55.    prevent these from being compiled and used. */
  56.  
  57. /* #define PNG_NO_STDIO */
  58.  
  59. /* this macro protects us against machines that don't have function
  60.    prototypes.  If your compiler does not handle function prototypes,
  61.    define this macro.  I've always been able to use _NO_PROTO as the
  62.    indicator, but you may need to drag the empty declaration out in
  63.    front of here, or change the ifdef to suit your own needs. */
  64. #ifndef PNGARG
  65.  
  66. #ifdef OF
  67. #define PNGARG(arglist) OF(arglist)
  68. #else
  69.  
  70. #ifdef _NO_PROTO
  71. #define PNGARG(arglist) ()
  72. #else
  73. #define PNGARG(arglist) arglist
  74. #endif /* _NO_PROTO */
  75.  
  76. #endif /* OF */
  77.  
  78. #endif /* PNGARG */
  79.  
  80. /* enough people need this for various reasons to include it here */
  81. #if !defined(MACOS) && !defined(RISCOS)
  82. #include <sys/types.h>
  83. #endif
  84. /* need the time information for reading tIME chunks */
  85. #include <time.h>
  86.  
  87. /* for FILE.  If you are not using standard io, you don't need this */
  88. #include <stdio.h>
  89.  
  90. /* include setjmp.h for error handling */
  91. #include <setjmp.h>
  92.  
  93. #ifdef BSD
  94. #include <strings.h>
  95. #else
  96. #include <string.h>
  97. #endif
  98.  
  99. /* other defines for things like memory and the like can go here.  These
  100.    are the only files included in libpng, so if you need to change them,
  101.    change them here.  They are only included if PNG_INTERNAL is defined. */
  102. #ifdef PNG_INTERNAL
  103. #include <stdlib.h>
  104. #include <ctype.h>
  105. #include <math.h>
  106.  
  107. /* other defines specific to compilers can go here.  Try to keep
  108.    them inside an appropriate ifdef/endif pair for portability */
  109.  
  110. /* for some reason, Borland C++ defines memcmp, etc. in mem.h, not
  111.    stdlib.h like it should (I think).  Or perhaps this is a C++
  112.    feature */
  113. #ifdef __TURBOC__
  114. #include <mem.h>
  115. #include "alloc.h"
  116. #endif
  117.  
  118. #ifdef _MSC_VER
  119. #include <malloc.h>
  120. #endif
  121.  
  122. /* this controls how fine the dithering gets.  As this allocates
  123.    a largish chunk of memory (32K), those who are not as concerned
  124.    with dithering quality can decrease some or all of these */
  125. #define PNG_DITHER_RED_BITS 5
  126. #define PNG_DITHER_GREEN_BITS 5
  127. #define PNG_DITHER_BLUE_BITS 5
  128.  
  129. /* this controls how fine the gamma correction becomes when you
  130.    are only interested in 8 bits anyway.  Increasing this value
  131.    results in more memory being used, and more pow() functions
  132.    being called to fill in the gamma tables.  Don't get this
  133.    value less then 8, and even that may not work (I haven't tested
  134.    it). */
  135.  
  136. #define PNG_MAX_GAMMA_8 11
  137.  
  138. #endif /* PNG_INTERNAL */
  139.  
  140. /* the following uses const char * instead of char * for error
  141.    and warning message functions, so some compilers won't complain.
  142.    If you want to use const, define PNG_USE_CONST here.  It is not
  143.    normally defined to make configuration easier, as it is not a
  144.    critical part of the code.
  145.    */
  146.  
  147. #ifdef PNG_USE_CONST
  148. #  define PNG_CONST const
  149. #else
  150. #  define PNG_CONST
  151. #endif
  152.  
  153. /* The following defines give you the ability to remove code
  154.    from the library that you will not be using.  I wish I
  155.    could figure out how to automate this, but I can't do
  156.    that without making it seriously hard on the users.  So
  157.    if you are not using an ability, change the #define to
  158.    and #undef, and that part of the library will not be
  159.    compiled.  If your linker can't find a function, you
  160.    may want to make sure the ability is defined here.
  161.    Some of these depend upon some others being defined.
  162.    I haven't figured out all the interactions here, so
  163.    you may have to experiment awhile to get everything
  164.    to compile.
  165.    */
  166.  
  167. /* Any transformations you will not be using can be undef'ed here */
  168. #define PNG_PROGRESSIVE_READ_SUPPORTED
  169. #define PNG_READ_INTERLACING_SUPPORTED
  170. #define PNG_READ_EXPAND_SUPPORTED
  171. #define PNG_READ_SHIFT_SUPPORTED
  172. #define PNG_READ_PACK_SUPPORTED
  173. #define PNG_READ_BGR_SUPPORTED
  174. #define PNG_READ_SWAP_SUPPORTED
  175. #define PNG_READ_INVERT_SUPPORTED
  176. #define PNG_READ_DITHER_SUPPORTED
  177. #define PNG_READ_BACKGROUND_SUPPORTED
  178. #define PNG_READ_16_TO_8_SUPPORTED
  179. #define PNG_READ_FILLER_SUPPORTED
  180. #define PNG_READ_GAMMA_SUPPORTED
  181. #define PNG_READ_GRAY_TO_RGB_SUPPORTED
  182. #undef  PNG_CORRECT_PALETTE_SUPPORTED
  183.  
  184. #define PNG_WRITE_INTERLACING_SUPPORTED
  185. #define PNG_WRITE_SHIFT_SUPPORTED
  186. #define PNG_WRITE_PACK_SUPPORTED
  187. #define PNG_WRITE_BGR_SUPPORTED
  188. #define PNG_WRITE_SWAP_SUPPORTED
  189. #define PNG_WRITE_INVERT_SUPPORTED
  190. #define PNG_WRITE_FILLER_SUPPORTED
  191. #define PNG_WRITE_FLUSH_SUPPORTED
  192.  
  193. /* any chunks you are not interested in, you can undef here.  The
  194.    ones that allocate memory may be expecially important (hIST,
  195.    tEXt, zTXt, tRNS) Others will just save time and make png_info
  196.    smaller.  OPT_PLTE only disables the optional palette in RGB
  197.    and RGB Alpha images. */
  198.  
  199. #define PNG_READ_gAMA_SUPPORTED
  200. #define PNG_READ_sBIT_SUPPORTED
  201. #define PNG_READ_cHRM_SUPPORTED
  202. #define PNG_READ_tRNS_SUPPORTED
  203. #define PNG_READ_bKGD_SUPPORTED
  204. #define PNG_READ_hIST_SUPPORTED
  205. #define PNG_READ_pHYs_SUPPORTED
  206. #define PNG_READ_oFFs_SUPPORTED
  207. #define PNG_READ_tIME_SUPPORTED
  208. #define PNG_READ_tEXt_SUPPORTED
  209. #define PNG_READ_zTXt_SUPPORTED
  210. #define PNG_READ_OPT_PLTE_SUPPORTED
  211.  
  212. #define PNG_WRITE_gAMA_SUPPORTED
  213. #define PNG_WRITE_sBIT_SUPPORTED
  214. #define PNG_WRITE_cHRM_SUPPORTED
  215. #define PNG_WRITE_tRNS_SUPPORTED
  216. #define PNG_WRITE_bKGD_SUPPORTED
  217. #define PNG_WRITE_hIST_SUPPORTED
  218. #define PNG_WRITE_pHYs_SUPPORTED
  219. #define PNG_WRITE_oFFs_SUPPORTED
  220. #define PNG_WRITE_tIME_SUPPORTED
  221. #define PNG_WRITE_tEXt_SUPPORTED
  222. #define PNG_WRITE_zTXt_SUPPORTED
  223.  
  224. /* some typedefs to get us started.  These should be safe on most of the
  225.    common platforms.  The typedefs should be at least as large
  226.    as the numbers suggest (a png_uint_32 must be at least 32 bits long),
  227.    but they don't have to be exactly that size. */
  228.  
  229. typedef unsigned long png_uint_32;
  230. typedef long png_int_32;
  231. typedef unsigned short png_uint_16;
  232. typedef short png_int_16;
  233. typedef unsigned char png_byte;
  234.  
  235. /* this is usually size_t. it is typedef'ed just in case you need it to
  236.    change (I'm not sure if you will or not, so I thought I'd be safe) */
  237. typedef size_t png_size_t;
  238.  
  239. /* The following is needed for medium model support. It cannot be in the
  240.    PNG_INTERNAL section. Needs modification for other compilers besides
  241.    MSC. Model independent support declares all arrays that might be very
  242.    large using the far keyword. The Zlib version used must also support
  243.    model independent data. As of version Zlib .95, the necessary changes
  244.    have been made in Zlib. The USE_FAR_KEYWORD define triggers other
  245.    changes that are needed. Most of the far keyword changes are hidden
  246.    inside typedefs with suffix "f". Tim Wegner */
  247.  
  248. /* SJT: Separate compiler dependencies */
  249. /* SJT: problem here is that zlib.h always defines FAR */
  250. #ifdef __BORLANDC__
  251. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  252. #define LDATA 1
  253. #else
  254. #define LDATA 0
  255. #endif
  256.  
  257. #if !defined(__WIN32__) && !defined(__FLAT__)
  258. #define PNG_MAX_MALLOC_64K
  259. #if (LDATA != 1)
  260. #ifndef FAR
  261. #define FAR __far
  262. #endif
  263. #define USE_FAR_KEYWORD
  264. #endif   /* LDATA != 1 */
  265.  
  266. /* SJT:  Possibly useful for moving data out of default segment.
  267.    Uncomment it if you want. Could also define FARDATA as const
  268.    if your compiler supports it.
  269. #  define FARDATA FAR
  270. */
  271. #endif  /* __WIN32__, __FLAT__ */
  272.  
  273. #endif   /* __BORLANDC__ */
  274.  
  275.  
  276. /* SJT:  Suggest testing for specific compiler first before
  277.    testing for FAR.  The Watcom compiler defines both __MEDIUM__
  278.    and M_I86MM, making reliance oncertain keywords suspect
  279. */
  280.  
  281. /* MSC Medium model */
  282. #if defined(FAR)
  283. #  if defined(M_I86MM)
  284. #     define USE_FAR_KEYWORD
  285. #     define FARDATA FAR /* SJT: added */
  286. #  endif
  287. #endif
  288.  
  289. /* SJT: default case */
  290. #ifndef FAR
  291. #   define FAR
  292. #endif
  293.  
  294. /* SJT: At this point FAR is always defined */
  295.  
  296. /* not used anymore, but kept for compatability */
  297. typedef unsigned char FAR png_bytef;
  298.  
  299. /* SJT: */
  300. #ifndef FARDATA
  301. #define FARDATA
  302. #endif
  303.  
  304. /* End medium model changes to be in zconf.h */
  305.  
  306. /* SJT: More typedefs */
  307. typedef void FAR *   png_voidp;
  308.  
  309.  
  310. /* SJT: Add typedefs for pointers */
  311. typedef png_byte        FAR * png_bytep;
  312. typedef png_uint_32     FAR * png_uint_32p;
  313. typedef png_int_32      FAR * png_int_32p;
  314. typedef png_uint_16     FAR * png_uint_16p;
  315. typedef png_int_16      FAR * png_int_16p;
  316. typedef PNG_CONST char  FAR * png_const_charp;
  317. typedef char            FAR * png_charp;
  318.  
  319. /*  SJT: Pointers to pointers; i.e. arrays */
  320. typedef png_byte        FAR * FAR * png_bytepp;
  321. typedef png_uint_32     FAR * FAR * png_uint_32pp;
  322. typedef png_int_32      FAR * FAR * png_int_32pp;
  323. typedef png_uint_16     FAR * FAR * png_uint_16pp;
  324. typedef png_int_16      FAR * FAR * png_int_16pp;
  325. typedef PNG_CONST char  FAR * FAR * png_const_charpp;
  326. typedef char            FAR * FAR * png_charpp;
  327.  
  328.  
  329. /* SJT: libpng typedefs for types in zlib. If Zlib changes
  330.    or another compression library is used, then change these.
  331.    Eliminates need to change all the source files.
  332. */
  333. typedef charf *         png_zcharp;
  334. typedef charf * FAR *   png_zcharpp;
  335. typedef z_stream *      png_zstreamp; /* zlib won't accept far z_stream */
  336.  
  337.  
  338. /* User may want to use these so not in PNG_INTERNAL. Any library functions
  339.    that are passed far data must be model independent. */
  340. #if defined(USE_FAR_KEYWORD)  /* memory model independent fns */
  341. #   define png_strcpy _fstrcpy
  342. #   define png_strcat _fstrcat
  343. #   define png_strlen _fstrlen
  344. #   define png_strcmp _fstrcmp
  345. #   define png_memcmp _fmemcmp      /* SJT: added */
  346. #   define png_memcpy _fmemcpy
  347. #   define png_memset _fmemset
  348. #else /* use the usual functions */
  349. #   define png_strcpy strcpy
  350. #   define png_strcat strcat
  351. #   define png_strlen strlen
  352. #   define png_strcmp strcmp
  353. #   define png_memcmp memcmp     /* SJT: added */
  354. #   define png_memcpy memcpy
  355. #   define png_memset memset
  356. #endif
  357. /* End of memory model independent support */
  358.  
  359. #endif /* PNGCONF_H */
  360.  
  361.